Half width counting leading zero circuit

ABSTRACT

A circuit and method are provided for storing a data word in a latch and determining the number of consecutive equal value bits within the data word. The data word consists of bits stored in unique bit positions and having a least significant bit position and a most significant bit position. The data word is examined to determine the number of consecutive bits having the same numeric value. The invention first corrects for any single bit anomaly within the consecutive equal value sequence, counts the number of consecutive bits having this equal value using logic that examines only every other bit position of the stored data word and provides a numeric value representing this number of consecutive equal value bits.

RELATED APPLICATIONS

This application is related to the following U.S. Patent Applications filed the same day as the present application and having the same assignee: U.S. patent application Ser. No. 11/844,393 now U.S. Pat. No. 7,797,131 and U.S. patent application Ser. No. 11/844,405.

BACKGROUND OF THE INVENTION

1. Technical Field

The present invention relates in general to a circuit and method for providing a numeric indication of the number of leading zeros in a binary data word. In particular, the present invention relates to a circuit and method for providing a leading zeros count with a more efficient component structure.

2. Description of the Related Art

Modern data processing systems use binary numbers for the computation of data. This computation includes both integer arithmetic and floating-point arithmetic. One common operation that is used in floating-point arithmetic, is determining the number of leading zeros in a data word for normalization, i.e., for removing the zeroes just past the decimal point such that the first bit after the decimal point is a “1”. Special circuitry has been devised to determine perform this function and is illustrated in U.S. Pat. No. 5,844,826 entitled “Leading Zero Count Circuit.” Another example of a count leading zero specialized circuit will be discussed in this application. Other applications where this function may be useful would be where the data format is monotonic, i.e., where data is a series of consecutive ‘0’s followed by a series of consecutive ‘1’s as may be generated by a mask generator, successive approximation A/D converter, or a chain of inverters as described in this application.

In a patent application entitled “On-Chip Frequency Response Measurement” U.S. patent application Ser. No. 11/844,393 now U.S. Pat. No. 7,797,131 also assigned to IBM and herein incorporated by reference, the count leading zeros function is used as part of a frequency response measurement circuit. The function of this count leading zeros circuit is the same as the count leading zeros circuit function and floating-point arithmetic applications. In addition, a second co-pending patent application entitled “Data Correction Circuit” U.S. patent application Ser. No. 11/844,405 also assigned to IBM and herein incorporated by reference, addresses a correction circuit that is used to correct input values to the count leading zeros circuit.

This frequency measurement circuit is used as part of a larger apparatus that determines certain physical characteristics of an operating integrated circuit. This larger apparatus provides a scaled voltage to the integrated circuited itself and is to the disclosed in patent applications entitled “Using IR Drop Data for Instruction Thread Direction,” U.S. patent application Ser. No. 11/671,613, “On-Chip Adaptive Voltage Compensation,” U.S. patent application Ser. No. 11/671,485 now U.S. Pat. No. 7,936,153; “Using Performance Data for Instruction Thread Direction,” U.S. patent application Ser. No. 11/671,627 now U.S. Pat. No. 7,779,235; “Using Temperature Data for Instruction Thread Direction,” U.S. patent application Ser. No. 11/671,640; “Integrated Circuit Failure Prediction,” U.S. patent application Ser. No. 11/671,599 now U.S. Pat. No. 7,560,945; “Instruction Dependent Dynamic Voltage Compensation,” U.S. patent application Ser. No. 11/671,579 now U.S. Pat. No. 7,895,454; “Temperature Dependent Voltage Source Compensation,” U.S. patent application Ser. No. 11/671,568; “Fan Speed Control from Adaptive Voltage Supply,” U.S. patent application Ser. No. 11/671,555 now U.S. Pat. No. 7,865,750; and “Digital Adaptive Voltage Supply,” U.S. patent application Ser. No. 11/671,531 now U.S. Pat. No. 7,714,635; each assigned the IBM Corporation and herein incorporated by reference.

As can be seen by the examination of the U.S. Pat. No. 5,844,826, the circuitry to provide this count leading zeros function is complex. What is needed is a simpler structure to provide this numeric count.

SUMMARY

In accordance with the present invention, a logic circuit is provided that includes a latch having N bits of a data word, each bit having a unique bit position, a consecutive equal value sequence count circuit connected to every other bit position of the latch data word and providing a count output data word of less than N bits, a single bit correction circuit connected to each bit position of the latch data word and having a single bit output and a bit assembly including the single bit output and the count output data word. This logic circuit provides a numeric count of the number of consecutive equal value bits in sequence contained in the latch data word.

In one embodiment of the present invention, a logic circuit is provided that includes a latch having N bits of a data word in N bit positions including a most significant bit position and a least significant bit position, a data correction circuit including logic gates connected to each of the N bit positions of the latch and providing a first output data word having N bit positions, a count leading zeros circuit connected to every other bit position of the data correction circuit first output data word and providing a count leading zeros circuit output data word having N/2 bit positions, a least significant bit correction circuit connected to each bit position of the data correction circuit first output data word and providing a single bit output, and an assembly of bits including the single bit output from the least significant bit correction circuit and the count leading zeros circuit output data word wherein the assembly of bits represents the number of consecutive equal value sequence bits within the latch data word.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention may be better understood, and its numerous objects, features, and advantages made apparent to those skilled in the art by referencing the accompanying drawings.

FIG. 1A is a schematic diagram illustrating a frequency measurement circuit that includes a count leading zeros component;

FIG. 1B is a schematic diagram of a prior art count leading zeros circuit circuit;

FIG. 2 is a diagram of a digital data word of N bits;

FIG. 3 is a diagram of a digital data word of N bits including a “0” bit contained within a series of “1” bits;

FIG. 4 is a schematic diagram of a correction circuit that corrects for the occurrence of a “0” bit contained in a series “1” bits;

FIG. 5 is a schematic diagram of a count leading zero circuit connected to every odd numbered that position of the latch;

FIG. 6 is a schematic diagram of a “Plus One” circuit that provides a correction bit in the present invention; and

FIG. 7 is a block diagram illustrating the component structure of the present invention.

DETAILED DESCRIPTION

The following is intended to provide a detailed description of an example of the invention and should not be taken to be limiting of the invention itself. Rather, any number of variations may fall within the scope of the invention, which is defined in the claims following the description.

FIG. 1A is a schematic diagram of a frequency measuring circuit. The operation of the circuitry contained in FIG. 1A is discussed in detail in the co-pending patent application Ser. No. 11/844,393. In FIG. 1A, block 180 contains several serially connected inverters such as 114 and 118. These inverters include outputs that are connected to latches such as latches 130 and 132. A pulse generator 110 provides a single pulse on line 112 inverter 114 upon receiving an Enable signal on line 103. Line 112 is connected to latch 130. Line 128 also connects the pulse generator 110 to latch 130. The signal on line 128 provides a latch/reset signal to latch 130 and latch 132 along with the other latches shown in block 180. The pulse generator 110 receives a signal on line 120 from a clock circuit 126 and with the Enable signal generates a single pulse on line 112. In the manner shown, each of the latches will store a binary bit that indicates those inverters that have propagated the pulse from the pulse generator 110. In this configuration, those latches that have received the pulse on line 112 or the output of the inverters on lines such as line 124 will store binary bits having alternating values. Inverters, such as inverter 138 are connected to the odd-numbered latch outputs in the assembly of block 180 in order to convert the data from those odd-numbered latches so that the resulting output from all latches will have a value of “1” for those latches that have received propagated signal from their respective connected inverters and a value of “0” for those latches connected to inventers that have not propagated pulse. The N bit wide data output from block 180 provides an N bit wide binary value representing the number of inverters that have propagated the pulse from pulse generator 110. This binary value is inverted in inverter 100 and is provided to a count leading zeros circuit 102 which provides a numeric value to register 104 through a multiplexer 105 controlled by the Enable signal on line 103. The multiplexer provides the value previously stored in register 104 and an input to register 104 when the Enable signal is not present on line 103. The numeric value in register 104 represents the frequency response of the integrated circuit containing block 180.

FIG. 1B is a schematic diagram illustrating a prior art count leading zeros circuit. Blocks 202, 204, 206, 208, 210, 212, 214, 216, 238 and 250 are identical 4 to 2 priority encoders. Line 200 is a 32-bit wide line divided into four bit wide lines provided to the encoders 202, 204, 206, 208, 210, 212, 214 and 216 as shown. The output of the encoders is a two bit wide data word on line 226 for multiplexer 234 and a single bit on line 218 for encoder 238. The single bit output on lines 218, 220, 222, and 224 are combined into four bits on line 225 into encoder 238. The two bit output on line 226 is connected to a 4 to 1 multiplexer 234 which also receives 2 bit inputs from encoders 204, 206 and 208. Multiplexer 234 received a two bit control input from line 240 provided by 238 to determine a two bit output on line 248. As can be seen from FIG. 1B, encoders 210, 212, 214, 216, 250 and multiplexer 236 are connected to operate in a similar manner. The two encoders 238 and 250 are connected to a multiplexer 254 that includes a control signal from line 239. Multiplexer 258 includes inputs of a two bit wide data word on line 248 from multiplexer 234 and a two bit wide data word on line 252 from multiplexer 236. Additionally multiplexer 258 receives a control signal from line 239. The output of multiplexer 258 is a two bit wide data word on line 266 which is concatenated with the two bit wide output of multiplexer 254 on line 264 and further is concatenated with the single bit output on line 262 to form a five bit output on line 268 as shown. NOR gate 260 receives inputs from lines 239 and line 242 and provides an ‘all zero’ indication on line 270. The circuitry of FIG. 1B operates to count the number of leading zeros in the 32-bit wide binary data word on line 200 and provides a five bit wide numeric count on line 268 representing the number of leading zeros that have been counted for the 32-bit wide data word. If no zeros are present in the 32-bit wide data word on line 200, the NOR gate 260 will indicate a value of “1.”

It can be appreciated that the circuitry in FIG. 1B is complex. If the data word to be examined for leading zeros is 64 bits rather than 32 bits, not only do the number encoders more than double but the number of levels of multiplexers increases from two levels to threes. Not only does this increase the cost of the circuitry but it decreases the circuit efficiency because of the addition level of multiplexers.

FIG. 2 is a diagram illustrating the data contents of a latch assembly such as in block 180 of FIG. 1A. This diagram includes bit positions from position 0 (the most significant bit position) to position N (the least significant bit position). This diagram also includes an example of typical data showing 1's and 0's and would be typical internal data word from the frequency measurement circuit described in Ser. No. 11/844,393 which provides a numeric indication of the frequency response of an integrated circuit.

FIG. 3 is a diagram (like FIG. 2) showing the contents of a latch assembly similar to that of block 108 (FIG. 1A) in their respective latch bit positions. It should be noted in area 300 that this sequence of 1's is not consistently consecutive as the typical data that is shown in FIG. 2. This sequence is FIG. 3 is referred to as containing a bubble, i.e., a 0 interrupting a sequence of 1's. This bubble output may be a result of the timing differences between the latches Block 108. The latches are capturing successive falling and rising edges. It is possible that the latch setup time for a falling edge is smaller than the latch setup time for a rising edge. If the difference in the setup times is such that it is greater than the propagation delay of an inverter, it is possible to obtain a “bubble” in one of the latch bits. In a full conventional CLZ circuit (i.e., a CLZ circuit with N inputs instead of N/2 inputs) such a bubble occurrence does not create an error because the CLZ circuit looks for the first ‘1’ scanning from the MSB to LSB and once it finds a ‘1’, it does not care about bubbles past this ‘1’. In other words, the information contained in the bit closer to the MSB of the input word is more significant than the bit where there is a bubble, and so the bubble is ignored. In this current application, removal of the bubble is critical because all bits are not being provided to the CLZ circuit. So if a preceding bit that was set to ‘1’ could have potentially masked the bubble, but it may not be used because we look at every other bit. Because of this bubble data, the contents of this latch must be corrected so that the contents shows a consistent series of ones adjacent to a consistent series of a zeros in order that a N/2 or half-width count leading zeros operation can accurately occur and a correct numeric value representing the frequency response can be provided.

FIG. 4 is a schematic diagram of circuit that can correct such a problem, i.e., a bubble correction or a data correction circuit such as described in the co-pending patent application Ser. No. 11/844,393. The bubble correction circuit includes a series of digital logical gate assemblies 400 through 410 as shown in FIG. 4 that are connected to the latch bit positions of latch 412 representing the latch inputs from an assembly such as Block 108 of FIG. 1A. Latch 412 includes single bit positions L0, L1, L2, through LN as shown. Specifically latch position L0 of latch 412 is connected to a NAND gate 404 and directly to bit position 0 of bit group 414. Latch positions (in latch 412) L1 and L2 are connected an OR gate 402 whose output is connected as the other input to the NAND gate 404. The output of the NAND gate 404 is connected to the bit position 1 of bit group 414. Likewise logic assembly 406 is connected to the latch 412 bit positions L1, L2 and L3 as shown. Note that the bit positions such as L1 and L2 are repeated for the logic assembly 406 for clarity. The output of assembly 406 provides bit position 2 for bit group 414. Like logic assembly 406, logic assembly 407 receives bit data from bit positions L2, L3 and L4 and shown to provide bit position 3 for bit group 414. Consecutively connected logic assemblies such as 408 and 410 are provided as shown in FIG. 4 and would be similarly connected to their respective bit positions of latch 412 and bit group 414. In logic assembly 410, bit position LN-1 is connected to the NAND gate as shown with the bit position LN and a ground input connected to the OR gate. Like the other logic assemblies, the output of logic assembly 410 is connected to the N bit position of bit group 414.

There is a non-detectable error condition where the last bit should indicated a propagation of the pulse but because of the timing delay of its latch, the pulse propagation will not be shown (i.e., the resulting bit will indicated that the pulse was not propagated). Since this error is a single bit error, a design decision was made to correct a ‘bubble’ type of error in the same manner. In other words, when a bubble is detected, the correction will include a change of the error bit from indicating no pulse propagated to indicating a pulse propagated and the next adjacent bit position (the next least significant bit position) that indicated that a pulse was propagated will also be changed to indicate that the pulse was not propagated. Therefore both the detected and the non-detected error conditions will be limited to a single bit error in the same manner (an error of the least significant bit position) so to minimize the error effect. Since these measurements are used in a relative manner rather than being used as absolute values, the single bit error is not significant. It should be apparent to those skilled in the art that other alternative techniques may be used to correct the detectable error condition.

FIG. 5 is the illustration of a bit group 500 having bit positions 0 through N as shown. The bit group 500 is connected, as shown, to an N/2 count leading zeros circuit 506. In FIG. 5, only the odd-numbered bit positions (bits 1, 3, 5, etc.) are connected to the count leading zeros circuit 506. In other words, the even numbered positions are not connected. Therefore, the count leading zeros circuit 506 is only using only half of the bit positions of latch 500 and this number is output on line 504. By only having to count half of the latch bit positions, circuitry is saved. There are also savings in area, timing and routing resources.

FIG. 6 is a least significant bit correction circuit which examines all the bit positions of latch 600 to provide a single bit output online 610 when necessary. This circuit determines if the total number of is (or 0s) in the corrected data is an odd number. If the number of is (or 0s) is an even number, then the total number of is (or 0s) in the corrected data is just twice of the number at the output of the count leading zeros circuit. If the number of is (or 0s) is an odd number, then the total number of is (or 0s) in the corrected data is just twice of the number at the output of the count leading zeros circuit plus one. Note that for obtaining twice the value, an explicit multiplier is not needed. Instead, a one bit left-shift operation upon the output of the N/2 CLZ is performed.

The least significant bit correction circuit 612, termed a ‘Plus One’ circuit, includes a series of exclusive NOR and AND gates shown as gates 602, 604 and 606 that are connected to the consecutive bit position contents of a latch 600. While only three gates are shown, the actual number of exclusive NOR gates connected would be half the number of bits in the latch. The outputs of these exclusive NOR gates 602, 604, . . . , 606 are connected to an AND gate 608 that provides a single bit output on line 610.

FIG. 7 is a block diagram illustrating the contents of the inventive circuit that takes the N bits from a latch 700 and provides them to a data correction circuit 702. The output of the data correction circuit 702 is provided on line 706 to the ‘Plus One’ circuit 712 on line 708. This ‘Plus One’ circuit 702 is illustrated in FIG. 6. The other output of the data correction circuit 702 is provided on lines 706 to a N/2 count leading zeros circuit 710 which is the count leading zeros circuit of FIG. 5 that is connected to every odd numbered bit position of the the data correction circuit 702. The output of the count leading zeros circuit 710 is provided on line 716 and consists of bit positions 0 through log₂ (N/2)−1 in parallel where N is the number of bit positions in the data word that is stored in Latches 700. Likewise the ‘Plus One’ circuit 712 is providing a single bit output on line 714 which is combined (or concatenated) with the parallel bits output on lines 716 to form a complete numeric indication on line 722. Line 714 provides the least significant bit position of the data whose most significant bit positions are provided on lines 716 to form the data on line 722 which is input to multiplexer 720. The multiplexer 720 includes an Enable line 723 which, when active, provides the contents of line 722 through line 719 to latch 718 for storage. When the Enable line 722 is not active, the contents of latch 718 are provided back through line 721 as an input through the multiplexer 720 to latch 718 to ensure the contents remain unchanged until the Enable line 723 becomes active again.

Therefore, FIG. 7 illustrates a new way to perform the count leading zeros function more efficiently by using only a N/2 count leading zeros circuit with a least significant bit correction circuit (the ‘Plus One’ circuit). It should be noted that this circuit takes advantage of the monotonic nature of the input data and reduces the circuitry needed to perform a CLZ operation. If the data were random, then a regular or full N bit wide CLZ circuit would be needed.

While particular embodiments of the present invention have been shown and described, it will be obvious to those skilled in the art, based upon the teachings herein, that changes and modifications may be made without departing from this invention and its broader aspects. Therefore, the appended claims are to encompass within their scope all such changes and modifications as are within the true spirit and scope of this invention. Furthermore, it is to be understood that the invention is solely defined by the appended claims. It will be understood by those with skill in the art that if a specific number of an introduced claim element is intended, such intent will be explicitly recited in the claim, and in the absence of such recitation no such limitation is present. For non-limiting example, as an aid to understanding, the following appended claims contain usage of the introductory phrases “at least one” and “one or more” to introduce claim elements. However, the use of such phrases should not be construed to imply that the introduction of a claim element by the indefinite articles “a” or “an” limits any particular claim containing such introduced claim element to inventions containing only one such element, even when the same claim includes the introductory phrases “one or more” or “at least one” and indefinite articles such as “a” or “an”; the same holds true for the use in the claims of definite articles. 

1. A logic circuit comprising: a latch having N bits of a data word, each bit having a unique bit position; a data correction circuit connected to each of the N bit positions of the latch and adjusting the latch data word to remove any single bit variance within a consecutive equal value bit sequence and providing the adjusted data, said adjusted data having N bit positions; a consecutive equal value sequence count circuit connected to data of every other bit position of said adjusted data and providing output data having a word width of less than N bits, wherein said consecutive equal value sequence count circuit output data is a number of counted consecutive equal value sequence bits of every other bit of said adjusted data; a single bit correction circuit connected to each bit of the data correction latch circuit and logically combining every bit of said adjusted data and providing having a single bit output; and a bit assembly concatenating the single bit output to the consecutive equal value sequence count circuit output, wherein said assembly provides an output data word representing a number of consecutive equal value sequence bits of the latch data word.
 2. A logic circuit according to claim 1 wherein said consecutive equal value sequence count circuit output is a N/2 bits wide data word.
 3. A logic circuit according to claim 1 wherein said output data word has a most significant bit position and a least significant bit position and wherein the single bit correction circuit is connected to provide the least significant bit of said bit assembly output data word.
 4. A logic circuit according to claim 1 wherein said data correction circuit is connected to provide each bit output of the latch circuit to the single bit correction circuit.
 5. A method of providing a numeric value representing the number of consecutive equal value sequence bits in a data word, said method comprising the steps of: storing the data word in a latch; adjusting the stored data word in a first circuit to remove any single bit variance within a consecutive equal value bit sequence and outputting the adjusted data; counting a number of consecutive equal value bits in the adjusted data word in a second circuit by counting only every other bit of the adjusted data having a constant bit value corresponding to the consecutive equal value bit sequence; providing a single correction bit by logically combining every bit of the adjusted data word in a third circuit; and concatenating the single correction bit to the counted number of consecutive equal value bits to provide the numeric value representing the number of consecutive equal value sequence bits in the stored data word.
 6. A method according to claim 5 wherein the concatenating step places the single correction bit as a least significant bit of the numeric value.
 7. A computer program product stored in a non-transitory computer operable media, the computer operable media containing instructions for execution by a computer, which, when executed by the computer, cause the computer to implement a method for providing a numeric value representing the number of consecutive equal value sequence bits in a data word including the steps of: storing the data word in a latch; adjusting the stored data word in a data correction circuit to remove any single bit variance within a consecutive equal value bit sequence and outputting the adjusted data; counting a number of consecutive equal value bits in the adjusted data word by counting only every other bit of the adjusted data having a constant bit value corresponding to the consecutive equal value bit sequence; providing a single correction bit by logically combining every bit of the adjusted data word; and concatenating the single correction bit to the counted number of consecutive equal value bits to provide the numeric value representing the number of consecutive equal value sequence bits in the stored data word.
 8. The computer program product of claim 7 wherein the concatenating step places the single correction bit as a least significant bit of the numeric value.
 9. A logic circuit comprising: a latch having N bits of a data word in N bit positions including a most significant bit position and a least significant bit position; a data correction circuit including logic gates connected to each of the N bit positions of the latch and adjusting the latch data word to remove any single bit variance within a consecutive equal value bit sequence and providing the adjusted data, said adjusted data having N bit positions; a count leading zeros circuit connected to every other bit position of said adjusted data and providing a count leading zeros circuit output data word having N/2 bit positions, wherein said count leading zeros circuit output data word is a number of counted leading zero bits of every other bit of said adjusted data; a least significant bit correction circuit connected to each bit position of said adjusted data and logically combining every bit of said adjusted data and providing a single bit output; and an assembly concatenating the single bit output from the least significant bit correction circuit to the count leading zeros circuit output data word, said assembly representing the number of leading zero bits of the latch data word.
 10. The logic circuit of claim 9 wherein said single bit correction circuit includes a plurality of two input exclusive NOR gates, each of said exclusive NOR gate inputs connected to a unique one of said latch data word bit positions and outputs of the plurality of exclusive NOR gates connected as inputs to a single AND gate wherein the AND gate provides the single bit output from the least significant bit correction circuit. 